package com.example.demo.rabbit.producer;

import com.example.demo.rabbit.common.RabbitConstants;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class Producer {
    @Autowired
    private RabbitTemplate rabbitTemplate;


    @Scheduled(fixedDelay = 4000)
    public void send(){
        String message = "time:"+new Date();
        this.rabbitTemplate.convertAndSend(RabbitConstants.Queue.QUEUE_FROM,message);
    }

}
